<?php

/**
 * model_ware
 */

class Model_ware extends YOU {

	public function __construct()
	{
		parent::__construct();
	}

	/** 读取总数 **/
	public function count()
	{
		$row = $this->db->fetchRow("SELECT COUNT(1) AS count FROM `tbl_ware`");

		$count = (int)$row['count'];

		return $count;
	}

	/** 读取成配置 **/
	public function getIni()
	{
		$ware_lists = $this->getAll();
		foreach ($ware_lists as $key => $value){
			$ware[$value['ware_id']] = $value['ware_name'];
		}

		return $ware;
	}

	/** 读取列表 **/
	public function getAll($field = "*")
	{
		$ware_lists = $this->db->fetchAll("SELECT {$field} FROM `tbl_ware`");

		return $ware_lists;
	}
	/** 读取列表 **/
	public function getTypeAll($field = "*")
	{
		$ware_lists = $this->db->fetchAll("SELECT {$field} FROM `tbl_ware_type`");

		return $ware_lists;
	}
	/** id读取单条 **/
	public function getInfo($ware_id ,$field = "*")
	{
		$ware_lists = $this->db->fetchRow("SELECT {$field} FROM `tbl_ware` WHERE ware_id ='{$ware_id}'");

		return $ware_lists;
	}
	/** id读取分类单条 **/
	public function getTypeInfo($type_id ,$field = "*")
	{
		$ware_lists = $this->db->fetchRow("SELECT {$field} FROM `tbl_ware_type` WHERE type_id ='{$type_id}'");

		return $ware_lists;
	}
	/** id读取目录单条 **/
	public function getFolderInfo($folder_id ,$field = "*")
	{
		$ware_lists = $this->db->fetchRow("SELECT {$field} FROM `tbl_ware_folder` WHERE folder_id ='{$folder_id}'");

		return $ware_lists;
	}
	
}
?>